#include <algorithm>

class Solution
{
public:
    Solution() {}

    int smallestRangeI(vector<int> &nums, int k)
    {
        auto [minIt, maxIt] = minmax_element(nums.begin(), nums.end());
        return max(0, *maxIt - *minIt - 2 * k);
    }
};